<?php /* 	These code was generated using phpCIGen v 0.1.a (21/04/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com,
    #songbee	mukhlisona@gmail.com
	#CV. Trust Solution, jl. Saronojiwo 19 Surabaya, http://www.ts.co.id

	+ Module  		: t_bbmsalessum Model
	+ Description	: For record model process back-end
	+ Filename 		: c_t_bbmsalessum.php
 	+ creator 		: 
 	+ Created on 31/May/2011 09:41:28

*/

class M_lap_bayar extends CI_Model{

	//constructor
	function M_lap_bayar() {
		parent::__construct();
	}
		
	
	function get_list_bybayar($tgl_start, $tgl_end){
		$sql = "SELECT *
			FROM t_payment
			WHERE DATE_FORMAT(t_payment.payment_date,'%Y-%m-%d') 
				BETWEEN DATE_FORMAT('".$tgl_start."','%Y-%m-%d') AND DATE_FORMAT('".$tgl_end."','%Y-%m-%d')";
		
		$result = $this->db->query($sql);
		$nbrows = $result->num_rows();
	
		if($nbrows>0){
			foreach($result->result() as $row){
				$arr[] = $row;
			}
			$jsonresult = json_encode($arr);
			return '({"total":"'.$nbrows.'","results":'.$jsonresult.'})';
		} else {
			return '({"total":"0", "results":""})';
		}
	}
	
	function print_list_bybayar($tgl_start, $tgl_end){
		//full query
		$sql = "SELECT *
			FROM t_payment
			WHERE DATE_FORMAT(t_payment.payment_date,'%Y-%m-%d') 
				BETWEEN DATE_FORMAT('".$tgl_start."','%Y-%m-%d') AND DATE_FORMAT('".$tgl_end."','%Y-%m-%d')";
	
		$query = $this->db->query($sql);
		return $query->result();
	}

}
?>